

package cn.shengchao.base.event;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.RandomStringUtils;

import java.util.Date;

public class CourseUploadEvent extends BaseEvent<CourseUploadEvent.CourseUploadMessage> {

    public CourseUploadEvent(Object source) {
        super(source);
        this.buildEventMessage((CourseUploadEvent.CourseUploadMessage)source);
    }

    @Override
    public EventMessage<CourseUploadMessage> buildEventMessage(CourseUploadMessage data) {
        return EventMessage.<CourseUploadMessage>builder()
            .id(RandomStringUtils.randomNumeric(11))
            .timestamp(new Date())
            .data(data)
            .build();
    }

    @Override
    public String topic() {
        return "course_upload";
    }

    @Data
    @Builder
    @AllArgsConstructor
    @NoArgsConstructor
    public static class CourseUploadMessage {
        private String videoUrl;
    }
}
